<?php

namespace mpend\modules\home\models;

use Yii;

/**
 * 推荐文章模型
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class RecommendSearch extends \mpend\models\searchs\ArticleSearch {

    public $pagesize = false;
    public $limitSize = 20;

    /**
     * @inheritdoc
     */
    public function buildQuery($alias = 't') {
        $query = parent::buildQuery($alias);
        $query->orderBy([
            $alias . '.weight' => SORT_DESC,
        ]);
        return $query;
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'title',
            'channel',
            'views',
            'likes',
            'link' => 'mpLink',
        ];
    }

}
